package com.yf.esms.controller;

import com.yf.esms.common.CommonResult;
import com.yf.esms.common.ResultComponent;
import com.yf.esms.model.vo.ReportVo;
import com.yf.esms.service.SearchService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;

/**
 * @author 99698
 */
//@RestController
public class SearchController {

    @Autowired
    private SearchService searchService;

    @GetMapping("/search/{id}")
    @ApiOperation(value = "根据文档id查询")
    public ResultComponent searchById(@PathVariable("id") String id) throws IOException {
        ReportVo reportVo = searchService.searchById(id);
        return new ResultComponent(true,"根据文档id获取文档详情成功！","200",reportVo);
    }

    @GetMapping("search/keyword")
    @ApiOperation(value = "关键词高亮检索")
    public ResultComponent searchByKeyword(@RequestParam(value = "keyword")String keyword) throws IOException {
        List<ReportVo> reportVos = searchService.searchByKeyword(keyword);
        return new ResultComponent(true,"根据关键词高亮检索成功！","200",reportVos);
    }
}
